﻿using System;

namespace SpiderMonkey
{
    public sealed class Runtime : NativeObject
    {
        /// <summary>
        /// Initializes the JavaScript runtime.
        /// </summary>
        /// <param name="maxBytes">Maximum number of allocated bytes after which garbage collection is run.</param>
        public Runtime(uint maxBytes)
        {
            IntPtr ptr = Native.JS_Init(maxBytes);
            if (ptr == IntPtr.Zero) throw new SpiderException();
            Setup(ptr);
        }

        protected override void Dispose(bool disposing)
        {
            Native.JS_Finish(Pointer);
        }

        public static void Shutdown()
        {
            Native.JS_ShutDown();
        }
    }
}
